<template>
	<view class="discounts_list" @click="confirm">
		<view :class="[{'view':obj.can_use == 1},{'view1':obj.can_use !== 1}]">
			<p>￥<span>{{obj.amount}}</span></p>
			<view>
				<p>
					<span>{{obj.less_amount==0?'无门槛优惠卷':'满'+obj.less_amount+'可用'}}</span>
					<span class="date">有效期至：{{obj.use_end_time}}</span>
					<span style="color: red;font-size: 10px;margin-top: 20rpx;">{{obj.reason}}</span>
				</p>
			</view>
			<button v-if='fage'>去使用</button>
		</view>
	</view>
</template>

<script>
	export default {
		name: "discounts_list",
		data() {
			return {

			};
		},
		props: ['obj', 'fage', 'dzid', 'goodsId'],
		methods: {
			confirm() {
				console.log(this.goodsId)
				if (this.obj.can_use == 1 && this.goodsId && this.dzid) {
					uni.redirectTo({
						url: '/pages/orderForGoods/orderForGoods?coupon_amount=' + this.obj.amount +
							'&coupon_id=' + this.obj.id
					})
				}else if(this.fage){
					uni.switchTab({
						url:'/pages/home/home'
					})
				}else if(this.obj.id){
					uni.redirectTo({
						url: '/pages/orderForGoods/orderForGoods?&coupon_id=' + this.obj.id
					})
				}
			}
		}
	}
</script>

<style lang="less">
	.discounts_list {
		&>view{
			width: 690rpx;
			height: 180rpx;
			margin: 0 auto 20rpx;
			display: flex;
			align-items: center;
			padding: 42rpx 32rpx;
			box-sizing: border-box;
		}
		
		&>.view1{
			background: url('../../static/user/11.png');
			background-size: 100% 100%;
		}
		
		&>.view{
			background: url('../../static/user/58.png');
			background-size: 100% 100%;
		}

		&>view>button {
			width: 132rpx;
			height: 50rpx;
			line-height: 50rpx;
			border-radius: 25rpx;
			background-color: #4F8464;
			color: #fff;
			padding: 0;
			font-size: 12px;
		}

		&>view>view {
			color: #fff;

			&>p {
				display: flex;
				flex-direction: column;

				&>.date {
					font-size: 10px;
				}

				&>span {
					font-size: 15px;
				}
			}
		}

		&>view>p {
			color: #fff;
			font-size: 20px;
			width: 220rpx;

			&>span {
				font-size: 35px;
			}
		}
	}
</style>